<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %> 
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<!DOCTYPE html>
<html lang="zh-CN" >
<head>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>资产包信息列表</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
<div class="searchArea">
    <form id="searchBar">
        <div class="fieldset1 tabel_col clearFix">
          
          <div class="fieldBox" >
                <div class="label">融资基数</div>
                <div class="field">
                <select name="fncCrdnlt" id="fncCrdnlt" data-value=" ">
                    	<option value=" " selected="selected">请选择</option>
                         <c:forEach items="${fncCrdnltList }" var="fc">
                     		<option value="${fc.key }">${fc.value }</option>
                        </c:forEach>
                </select>
                </div>
            </div> 
			<div class="fieldBox">
                <div class="label">客户类型</div>
                <div class="field">
                    <select name="cstTypCd" id="cstTypCd" data-value=" ">
                    	<option value=" " selected="selected">请选择</option>
                         <c:forEach items="${cstTypCdList }" var="ct">
                     		<option value="${ct.key }">${ct.value }</option>
                        </c:forEach>
                    </select>
                </div>
            </div>        
			<div class="fieldBox">
                <div class="label">所属事业部</div>
                <div class="field">
                    <select name="buOrgCd" id="buOrgCd" data-value=" ">
                    	<option value=" " selected="selected">请选择</option>
                         <c:forEach items="${buOrgCdList }" var="bo">
                     		<option value="${bo.key }">${bo.value }</option>
                        </c:forEach>
                    </select>
                </div>
            </div>        
			<div class="fieldBox">
                <div class="label">是否办理抵押</div>
                <div class="field">
                    <select name="isMortgage" id="isMortgage" data-value=" ">
                    	<option value=" " selected="selected">请选择</option>
                         <c:forEach items="${isMortgageList }" var="im">
                     		<option value="${im.key }">${im.value }</option>
                        </c:forEach>
                    </select>
                </div>
            </div>        
			<div class="fieldBox">
                <div class="label">是否有保险</div>
                <div class="field">
                    <select name="isInsurance" id="isInsurance" data-value=" ">
                    	<option value=" " selected="selected">请选择</option>
                         <c:forEach items="${isMortgageList }" var="im">
                     		<option value="${im.key }">${im.value }</option>
                        </c:forEach>
                    </select>
                </div>
            </div>        
            <div class="fieldBox">
                <div class="label">租赁期数</div>
                <div class="field">
                   <input name="leaseTermMinQ" id="leaseTermMinQ" type="text" class="ui-textbox" value="" validate="{digits:true}">
                   <span>—</span>
                   <input name="leaseTermMaxQ" id="leaseTermMaxQ" type="text" class="ui-textbox" value="" validate="{digits:true}">
                </div>
            </div>
            <div class="fieldBox">
                <div class="label">剩余租赁期数</div>
                <div class="field">
                   <input name="surplusLeaseTermMinQ" id="surplusLeaseTermMinQ" type="text" class="ui-textbox" value="" validate="{digits:true}">
                   <span>—</span>
                   <input name="surplusLeaseTermMaxQ" id="surplusLeaseTermMaxQ" type="text" class="ui-textbox" value="" validate="{digits:true}">
                </div>
            </div>
           <div class="fieldBox">
                <div class="label">逾期天数</div>
                <div class="field">
                   <input name="ovdDaysMin" id="ovdDaysMin" type="text" class="ui-textbox" value="" validate="{digits:true}">
                   <span>—</span>
                   <input name="ovdDaysMax" id="ovdDaysMax" type="text" class="ui-textbox" value="" validate="{digits:true}">
                </div>
            </div>
            <div class="fieldBox">
                <div class="label">资产包名称</div>
                <div class="field">
                   <input name="assPackNm" id="assPackNm" type="text" class="ui-textbox" value="" ligerui="width: 200">
                </div>
            </div>
            <div class="clearFix"></div>
            <div class="btnsBox formBtns notRight">
            	<!-- 隐藏融资筛选编号 -->
				<input name="fncInsIdQ" id="fncInsIdQ" type="hidden" class="ui-textbox" value="">
				<input name="flag" id="flag" type="hidden" class="ui-textbox" value="0">
                <input name="prjid" id="prjid" type="hidden" class="ui-textbox" value="${prjid}">
                <span id="searchBtn" class="sq-button-round">查询</span>
                <span id="clearBtn" class="sq-button-round">清空</span>
                <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
            </div>
          </div>
        </form>
    </div>
</div>
<div id="ligergrid1" class="sq-grid"></div>

<script type="text/javascript">
	var grid = null;
	$(function () {
		$("#searchBar").ligerForm({validate: true});
		var _url = '<%=path%>/ass/asspackinfo/initPackInfoList.do?prjFlag=1';
    	$("#ligergrid1").ligerGrid({
    		url : _url,
    		method : 'get',
        	columns: [
        		{ display: '操作', width: 100 ,height:'100px', align:'center',
	            	render: function (rowdata, rowindex, value){
	            		var h='<a href="javascript:showDetail(';
	            		h+="'"+rowdata.id+"'";
	                    h+=')">查看</a>';
	                    h+=' | ';
	                    h+='<a href="javascript:inputRow(';
	            		h+="'"+rowdata.id+"'";
	                    h+=')">导入</a>';
	                	return h;
	            	}
	            },
	            { display: '资产编号', name: 'id', width: 150},
	            { display: '资产包名称', name: 'assPackNm', width: 150},
	            { display: '融资基数', name: 'fncCrdnltNm', width: 150},
	            { display: '客户类型', name: 'cstTypCdNm', width: 150,render: function (rowdata, rowindex, value){
            		var h=value;
	            	if(null==value ||""==value){
            			h="自然人,法人";
            		}
            		return h;
            	}},
	            { display: '事业部', name: 'buOrgCdNm', width: 150,render: function (rowdata, rowindex, value){
            		var h=value;
    	            	if(null==value ||""==value){
                			h="全部";
                		}
                		return h;
                	}},
	            { display: '是否办理抵押', name: 'isMgtNm', width: 100,render: function (rowdata, rowindex, value){
            		var h=value;
    	            	if(null==value ||""==value){
                			h="是,否";
                		}
                		return h;
                	}},
	            { display: '是否有保险', name: 'isInsureNm', width: 150,render: function (rowdata, rowindex, value){
            		var h=value;
    	            	if(null==value ||""==value){
                			h="是,否";
                		}
                		return h;
                	}}
	        ],
	        pageSize:10, 
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        height:'100%',
	        heightDiff:-2,
	        checkbox:false,
	        rownumbers:true

    	});
	    grid = liger.get("ligergrid1");
	    grid.setHeight(100);
	    $("#searchBar").ligerForm();

		$("#searchBtn").click(function(event) {
		    var form = new liger.get("searchBar");
		    if (!form.valid()) {
				top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO,SQ_type: "warning"});
				return false; //验证不通过，不执行以下代码
			}
		    $("#flag").val("1");
		    var data = form.getData();
		    for (var name in data){
		       grid.setParm(name,data[name]);
		    };
		   grid.reload();
		});
		
		$("#clearBtn").click(function(event) {
		    $("#resetBtn").click();  //重置 input-text
		    var form = liger.get("searchBar");
		    form.setData({  //重置select等特殊表单
		        "fncCrdnlt": " ",
		        "cstTypCd": " ",
		        "buOrgCd": " ",       
		        "isMortgage": " ",
		        "isInsurance": " ",
		        "leaseTermMinQ": "",
		        "leaseTermMaxQ": "",
		        "surplusLeaseTermMinQ": "",
		        "surplusLeaseTermMaxQ": "",
		        "ovdDaysMin": "",
		        "assPackNm":"",
		        "ovdDaysMax": ""
		    });
		});
	});
	
	//查看数据
	function showDetail(_id){
		var params = "?id="+_id+"&flag=0";
		Add_navTab('ass_pack_info_view_'+_id,'查看资产包筛选信息','<%=path%>/ass/asspackinfo/viewAssPackInfoDetail.do'+params);
	}
	
	//修改
	function inputRow(id){
		var prjid ="${prjid}";
		var wait_dialog;
		//导入之前判断资产包检查存在占用的支付表
		if(checkPack(id)){
			if(!confirm('资产包内包含"已占用"资产，是否剔除后导入？')){
				return ;
			}
		}
		$.ajax({
			type: 'get',
			dataType:'json',
			url: '<%=path%>/rfbuss/fncprjbscinfo/inportAssPack.do?id='+id+'&prjid='+prjid,
			beforeSend: function(){
		          wait_dialog=top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
			},
			success:function(msg){
				wait_dialog.close();
				 if(msg.success == 1){
					 parent.window.location.reload();
	    			  parent.$.ligerDialog.close();
	    			  parent.$(".l-dialog,.l-window-mask").css("display","none"); 
					// grid.reload();
					 //  var TAB=top.mainApp.parentTab;
				     //     var currentTabid=TAB.getSelectedTabItemID();
					//	 top.tab.removeTabItem(currentTabid);
				 }else{
					 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
				 }
			}
		});

	
	}
	function checkPack(id){
		var flag=false;
		$.ajax({
			type: 'post',
			dataType:'json',
			url: '<%=path%>/rfbuss/fncprjbscinfo/checkPack.do?id='+id,
			async:false,
			success:function(msg){
				
				 if(msg.success == 1){
					
					 flag=true;
				 }else{
					
				 }
			}
		});
		return flag;
	}
	function iframeResize () {
	    if (parent.mainApp) {
	        parent.mainApp.parentTab.onResize();
	    };
	}
	//格式化时间
	function renderDate(rowdata, index, value){
		var dateStr = "";
		if(null != value){
			var date = new Date(value);
			dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
		}
		return dateStr;
	}

</script>
</body>
</html>